CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(overseer)

SET(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMake/Modules
${CMAKE_MODULE_PATH}
)

# mixing the build system with the source code is ugly and stupid. enforce the opposite :)
IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
    MESSAGE(FATAL_ERROR "In-source builds are not allowed.")
ENDIF()

FIND_PACKAGE(OGRE)

IF(OGRE_FOUND)
    INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIRS})
ELSE()
    IF(WIN32)
        SET(OGRE_HOME OGRE_HOME-NOTFOUND CACHE PATH "Root directory of the Ogre installation.")
        MESSAGE(SEND_ERROR "Ogre could not be found! Please set the CMake variable OGRE_HOME to your Ogre installation.")
    ELSE()
        MESSAGE(SEND_ERROR "Ogre could not be found! Are you sure it's installed?")
    ENDIF()
ENDIF()

FIND_PACKAGE(OIS)

IF(OIS_FOUND)
    INCLUDE_DIRECTORIES(${OIS_INCLUDE_DIR})
ELSE()
    MESSAGE(SEND_ERROR "Failed to find OIS.")
ENDIF()

SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost COMPONENTS thread date_time filesystem system regex program_options)

IF(Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
    IF(UNIX)
        FIND_PACKAGE(Threads)
    ENDIF()
ELSE()
    SET(BOOST_ROOT BOOST_ROOT-NOTFOUND CACHE PATH "Root directory of the Boost installation.")
    MESSAGE(SEND_ERROR "Boost could not be found! Please set BOOST_ROOT to the root folder of your Boost installation.")
ENDIF()

FIND_PACKAGE(CEGUI COMPONENTS Ogre)

IF(CEGUI_FOUND)
    INCLUDE_DIRECTORIES(${CEGUI_INCLUDE_DIR})
ELSE()
    IF(WIN32)
        SET(CEGUI_HOME CEGUI_HOME-NOTFOUND CACHE PATH "Root directory of the CEGUI installation.")
        MESSAGE(SEND_ERROR "CEGUI could not be found! Please set the CMake variable CEGUI_HOME to your CEGUI installation.")
    ELSE()
        MESSAGE(SEND_ERROR "CEGUI could not be found! Are you sure it's installed?")
    ENDIF()
ENDIF()

FIND_PACKAGE(Lua51)
IF(LUA51_FOUND)
    INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
ELSE()
    MESSAGE(SEND_ERROR "Lua 5.1 could not be found!")
ENDIF()

INCLUDE_DIRECTORIES(Overseer/depends)
ADD_SUBDIRECTORY(Overseer)
